var sqlUpdateInstructions=null;
var fileData="";

var shortName = 'dps2'; 
var version = '1.0'; 
var displayName = 'PhoneGap Test Database'; 
var maxSize = 100000000; // in bytes y
var mydb = openDatabase(shortName, version, displayName, maxSize); 

/*
function processUpdateData()
{
	window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotSuchUpdateFS, failDown);
}

function gotSuchUpdateFS(fileSystem)
{
	try
	{
		fileSystem.root.getFile(localStorage.getItem("erId")+"_SyncDataUpdate.txt", null, gotSuchUpdateFileEntry, failDown2);
	}
	catch(e)
	{
		alert(e.message);
	}
}

function failDown2(error)
{
	console.log(error.code);
	alert("failed: "+error.message);
	//setTimeout(function(){removeCustomAlert()},3000);
}

function gotSuchUpdateFileEntry(fileEntry)
{
	fileEntry.file(gotSuchUpdateFile, failDown2);
}

function gotSuchUpdateFile(file)
{
	readAsText(file);
}

function readUpdateText(file)
{
    var reader = new FileReader();
    reader.onloadend = function(evt) {
        console.log("Read as text");
        console.log(evt.target.result);
        
        fileData=evt.target.result;
        sqlUpdateInstructions=fileData.split("\n");
        readUpdateInstructions();
    };
    
    reader.readUpdateText(file);
}

function readUpdateInstructions()
{
	mydb.transaction(updateDB, erroredCB2, successfulCB2);
}

function updateDB(tx)
{
    for(var i=0;i<sqlUpdateInstructions.length;i++)
    {
    	if(sqlUpdateInstructions[i].length>2)//@note: blank lines might cause a problem with sql lite, so get rid of them
		//length set to more than 2 to avoid problems with the blank lines
			tx.executeSql(sqlUpdateInstructions[i]);
	}
	//Popup.hide('modalPleaseWait');

	alert("Update completed");
	//setTimeout(function(){removeCustomAlert()},3000);
}

function erroredCB2(err) {
    alert("Error processing SQL: "+err.code);
	//setTimeout(function(){removeCustomAlert()},3000);
    alert("Error processing SQL: "+err.message);
	Popup.hide('modalPleaseWait');
	//setTimeout(function(){removeCustomAlert()},3000);
}

function successfulCB2(){
    alert("success!");
	//setTimeout(function(){removeCustomAlert()},2000);
}
*/